package service

import (
	"go_code/20211014/model"
)

type CustomerService struct {
	customers []model.Customer

	// 声明一个字段，表示当前切片含有多少个客户
	customerNum int
}

func NewCustomerService() *CustomerService {
	customerService := &CustomerService{}
	customerService.customerNum = 1
	customer := model.NewCustomer(1, "张三", "男", 20,
		"158****0925", "***@163.com")
	customerService.customers = append(customerService.customers, customer)

	return customerService
}

func (this *CustomerService) List() []model.Customer {
	return this.customers
}

func (this *CustomerService) Add(customer model.Customer) bool {
	this.customerNum++
	customer.Id = this.customerNum
	this.customers = append(this.customers, customer)

	return true
}
